import { config, Base_Api } from '../../config/index';


/** 获取商品列表 */
function mockFetchGood(ID = 0) {
  const { delay } = require('../_utils/delay');
  const { genGood } = require('../../model/good');
  return delay().then(() => genGood(ID));
}

/** 获取商品列表 */
export function fetchGood(ID = 0) {
  if (config.useMock) {
    return mockFetchGood(ID);
  }
  return new Promise((resolve) => {
    resolve('real api');
  });
}


/** 根据商品id 获取goods商品详细信息 */
export function get_goods_by_id(data) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: Base_Api + "/get_goods_by_id",
      method: "POST",
      data: data,
      success: (res) => {
        resolve(res)
      },
      fail: (err) => {
        reject(err)
      }
    })
  })

}